﻿@model Fap.AspNetCore.ViewModel.JqGridViewModel
@using Fap.AspNetCore.Controls.JqGrid
@using System.Linq
@{
    Column column = new Column("oper");
    column.SetLabel("打分详情");
    column.SetSortable(false);
    column.SetWidth(80);
    IEnumerable<Fap.Hcm.Service.Assess.PerfProgram> schemes = ViewBag.SchemeList;
}
<title>
    <fap-multilang lang-key="assess_monitor" default-content="考核监控"></fap-multilang>
</title>
<script>
    function initSchemeMonitorMenu() {
        var ids = $("#grid-monitor").jqGrid('getDataIDs');
        for (var i = 0; i < ids.length; i++) {
            var de = '';
            var cl = ids[i];
            var rd = jQuery('#grid-monitor').jqGrid('getRowData', cl);
            var fid = rd.Fid;
            var schemeUid = rd.ProgramUid;
            de += "<a  href='javascript:void(0)' onclick='showSchemeMonitor(\"" + fid + "\",\"" + schemeUid + "\")'>" + $.lang("view", "查看") + "</a>  ";

            jQuery('#grid-monitor').jqGrid('setRowData', ids[i], { oper: de });
        }
    }
    function showSchemeMonitor(fid, schemeUid) {
        bootboxWindow1($.lang("view", "查看"), basePath + "/Assess/Manage/Scoring", null, { examinerUid: fid, schemeUid: schemeUid });
    }
</script>
<div class="row">
    <div class="col-xs-12">
        <div class="widget-box">
            <div class="widget-header widget-header-flat">
                <h4 class="widget-title"> <fap-multilang lang-key="assess_consequent" default-content="考核结果"></fap-multilang></h4>

                <div class="widget-toolbar">
                    <a href="#" data-action="fullscreen" class="orange2">
                        <i class="ace-icon fa fa-expand"></i>
                    </a>
                </div>
                <div class="widget-toolbar">
                    <fap-button id="btnChart" content="完成情况统计" btn-tag="link" icon-before="fa fa-line-chart"></fap-button>
                </div>
                <div class="widget-toolbar">
                    <select class="chosen-select form-control" style="width:300px" id="selScheme" multi-placeholder="考核方案...">
                        <option value=""></option>
                        @foreach (var scheme in schemes.GroupBy(s => s.PrmCategoryMC))
                        {
                            <optgroup label="@scheme.Key">
                                @foreach (var sc in scheme)
                                {
                                    <option value="@sc.Fid">@(sc.PrmName+"("+sc.PrmStatusMC+")")</option>
                                }
                            </optgroup>
                        }
                    </select>
                </div>
            </div>
            <div class="widget-body">
                <div class="widget-main">
                    <fap-grid id="monitor" attach-column="column" grid-model="Model" on-grid-complete="initSchemeMonitorMenu" source-type="Local" shrink-fit="false" multi-select="true" multi-box-only="true"></fap-grid>
                </div>
            </div>
        </div>
    </div>
</div>
<script>

    var scripts = [null, null];
    $('.page-content-area').ace_ajax('loadScripts', scripts, function () {
        jQuery(function ($) {
            $(document).one('ajaxloadstart.page', function (e) {

            })
            $('.chosen-select').chosen({ allow_single_deselect: true, search_contains: true }).on("change", function () {
                refreshConsequent();
            });
            var refreshConsequent = function () {
                var c = $("#selScheme").val();
                if (c === "") {
                    return;
                }
                var filter = '{"groupOp":"AND","rules":[{"field":"ProgramUid","op":"eq","data":"' + c + '"}]}'

                reloadGrid("grid-monitor", { filters: filter })
            }
        
            $("#btnChart").on(ace.click_event, function () {
                var c = $("#selScheme").val();
                if (c === "") {
                    return;
                }
                bootboxWindow0($.lang("assess_complete_chart", "完成情况统计"), basePath + "/Assess/Manage/CompleteChart", null, { schemeUid:c});
            })
        })

    })
</script>



